package game.seungha;

import util.seungha.EffectView;
import android.app.Activity;

import android.graphics.Color;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;

public class Activity_Main extends Activity 
{
	int mCounter;
	int mColorList[] = {Color.WHITE, Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE};
	
	Spinner 		mSpinner;
	TextView 		mTextView;
	Activity 		mActivity;
	MediaPlayer 	mMediaPlayer;
	
	EffectView	mEffectView;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_main);
        
        mTextView = (TextView)this.findViewById(R.id.id_TextView_Title);
        
        mActivity = this;
        this.effectTitle();
        
        // Level Spinner Setting
        mSpinner = (Spinner) this.findViewById(R.id.id_Spinner_Level);
        ArrayAdapter<CharSequence> lvAdapter = ArrayAdapter.createFromResource(this, R.array.str_array_level, android.R.layout.simple_spinner_item);
        lvAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        mSpinner.setAdapter(lvAdapter);
        
        Listener_SelectLevel listener_SelectLevel = new Listener_SelectLevel(this);
        mSpinner.setOnItemSelectedListener(listener_SelectLevel);


        
        
        // Play Button Setting
        Button playButton = (Button) this.findViewById(R.id.id_Button_Play);
        playButton.setOnClickListener(new Listener_SimpleButton(this));
        
    }

    public void onStart()
    {
    	super.onStart();
    	mEffectView.start();

    	if( (mMediaPlayer!=null) && mMediaPlayer.isPlaying() ) mMediaPlayer.stop();
    	mMediaPlayer = MediaPlayer.create(mActivity, R.raw.game_ready);
    	mMediaPlayer.setLooping(true);
    	mMediaPlayer.start();
    }  

    protected void onStop() 
    {
        super.onStop();
        mEffectView.cancel();
        mMediaPlayer.stop();
    }
    
    
    
    private void effectTitle()
    {
    	mEffectView = new EffectView(this.mTextView, Color.RED);
    	mEffectView.start();
    	
    	
    	
/*    	
    	CountDownTimer titleTimer = new CountDownTimer(3600000, 500) 
        {
            public void onTick(long millisUntilFinished) 
            {
            	mCounter++;
            	mTextView.setTextColor(mColorList[mCounter%mColorList.length]);
            }
            public void onFinish() 
            {
            	
            }
        };
        
        titleTimer.start();
*/        
    }
}